# Maintainer: Alistair Francis <alistair@alistair23.me>
pkgname=bm818-tools
pkgver=0.7
pkgrel=0
pkgdesc="Free tools for use with the BM818 modem"
url="https://source.puri.sm/Librem5/bm818-tools"
arch="all"
license="GPL-3.0-or-later"
depends="
	ppp
	python3
	py3-pyserial
	py3-udev
	"

source="
	https://source.puri.sm/Librem5/bm818-tools/-/archive/v$pkgver/bm818-tools-v$pkgver.tar.gz
"
options="!check" # no test suite
builddir="$srcdir/bm818-tools-v$pkgver"

package() {
	install -D -m755 "usr/bin/bm818-fw-check" "$pkgdir/usr/bin/bm818-fw-check"
	install -D -m755 "usr/bin/bm818-tool" "$pkgdir/usr/bin/bm818-tool"
	install -D -m755 "usr/bin/bm818-volte" "$pkgdir/usr/bin/bm818-volte"
	install -D -m755 "usr/bin/bm818-volte-check" "$pkgdir/usr/bin/bm818-volte-check"

	for f in usr/share/bm818-tools/*; do
		install -D -t "$pkgdir/usr/share/bm818-tools/" $f;
	done

	# Copy the glade file for the GUI
	#
	# We don't install the desktop file (usr/share/applications/bm818-tool.desktop)
	# as by default the user won't have permissions to run the GUI. To access the
	# modem you need to be root or the user needs to be a member of the dialout group.
	#
	# We don't want to add the user to the dialout group just to run this GUI, instead
	# let's just expect the user to run the scripts or GUI from the terminal as
	# root (or add themselves to dialout).
	# See: https://source.puri.sm/Librem5/bm818-tools/-/issues/5
	install -D -m755 "data/bm818-tool.glade" "$pkgdir/usr/share/bm818-tools/bm818-tool.glade"
}

sha512sums="
1c3ff524e68271189da6d2cd0413d64acf6f3b5e0ce2c05d97e537aadc7dd82615597b51985ee23f790a51e4261e20480988133fb481dc0b042bc968e7ce6849  bm818-tools-v0.7.tar.gz
"
